<?php
	$webRoot = $this->app->getWebRoot();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>IPv6相关测试</title>
<?php		
	css::import($webRoot . 'js/index/css/reset.css');
	css::import($webRoot . 'js/index/css/common.css');
	css::import($webRoot . 'js/index/css/test.css');
	css::import($webRoot . 'js/index/css/responsiveslides.css');
	js::import($webRoot . 'js/jquery-1.8.3.min.js', $config->version);
	js::import($webRoot . 'js/responsiveslides.min.js', $config->version);
	js::import($webRoot . 'js/swfobject_modified.js', $config->version);	
?>
<script type="text/javascript">
	window.onload = function(){
		function getClientIp(){
			$.getJSON("http://v6.ipv6-test.com/api/myip.php?json&callback=?", function(result){
				// console.log(result);
				var ipv6 = result.address;
				if(ipv6 == ''){
					$.getJSON("http://v4.ipv6-test.com/api/myip.php?json&callback=?", function(result){
						// console.log(result);
						var ipv4 = result.address;
						$(".v4_v6").append("IPv4");
						$("#now_ip").text(ipv4);
					});
				}else{
					$(".v4_v6").append("IPv6");
					$("#now_ip").text(ipv6);
				}
			});
		}
		getClientIp();
	}
	
	//ipv4地址
	function getipv4(){
		$.getJSON("http://v4.ipv6-test.com/api/myip.php?json&callback=?", function(result){
		    // console.log(result);
		    var ipv4 = result.address;
			$(".v4_v6").empty();
			$(".v4_v6").append("IPv4");
			$("#now_ip").empty();
		    $("#now_ip").text(ipv4);
		});
	}
	//ipv6地址
	function getipv6(){
		$.getJSON("http://v6.ipv6-test.com/api/myip.php?json&callback=?", function(result){
		    // console.log(result);
		    var ipv6 = result.address;
			$(".v4_v6").empty();
			$(".v4_v6").append("IPv6");
			$("#now_ip").empty();
		    $("#now_ip").text(ipv6);
		});
	}
	//ip地址
	function getip(){
		//$.getJSON("http://v4v6.ipv6-test.com/api/myip.php?json&callback=?", function(result){
		    // console.log(result);
		    // var ipv4_6 = result.address;
			// $(".v4_v6").empty();
			// $(".v4_v6").append("IPv4");
			// $("#now_ip").empty();
		    // $("#now_ip").text(ipv4_6);
		// });
		$.getJSON("http://v6.ipv6-test.com/api/myip.php?json&callback=?", function(result){
			// console.log(result);
			var ipv4_6 = result.address;
			if(ipv4_6==''){
				$.getJSON("http://v4.ipv6-test.com/api/myip.php?json&callback=?", function(result){
					// console.log(result);
					var ipv4 = result.address;
					$(".v4_v6").empty();
					$(".v4_v6").append("IPv4");
					$("#now_ip").empty();
					$("#now_ip").text(ipv4);
				});
			}else{
				$(".v4_v6").empty();
				$(".v4_v6").append("IPv6");
				$("#now_ip").empty();
				$("#now_ip").text(ipv4_6);
			}	
		});
	}
	
	
	//轮播图
	$(function () {
	  // Slideshow 4
	  $("#slider4").responsiveSlides({
		auto: true,
		pager: false,
		nav: true,
		speed: 500,
		//namespace: "callbacks",
		before: function () {
		  $('.events').append("<li>before event fired.</li>");
		},
		after: function () {
		  $('.events').append("<li>after event fired.</li>");
		}
	  });
	});
</script>
</head>

<body>
	<div id="top" style="width: 100%; background-image:url(<?php echo $webRoot?>theme/default/images/top-bg.png); background-image: no-repeat; background-size:cover; "> 
  	<div style="width: 1200px; margin: 0 auto;"><img src="<?php echo $webRoot?>theme/default/images/whitelogo.png" class="logo"/></div> </div>	
<div id="wrap">
  
  <div id="mainnavi" style="background-image:url(<?php echo $webRoot?>theme/default/images/navi-bg.png);">
    <ul>
      <li><a href="<?php echo $this->createLink('index','index_ipv6');?>" target="_blank"><b>首 页</b></a></li>
      <li><a href="<?php echo $this->createLink('index','update');?>" target="_blank"><b>巴南区IPv6升级网站</b></a></li>
      <li><a href="<?php echo $this->createLink('index','netaddress');?>" target="_blank"><b>IPv6网址导航</b></a></li>
      <li><a href="<?php echo $this->createLink('index','state');?>" target="_blank"><b>IPv6链接状态监测</b></a></li>
      <li><a href="<?php echo $this->createLink('index','test');?>" class="current"><b>IPv6相关测试</b></a></li>
      <li class="nobodor"><a href="<?php echo $this->createLink('index','faq');?>" target="_blank"><b>FAQ</b></a></li>
    </ul>
  </div>
  <div id="banner">
    <div class="callbacks_container">
		<ul class="rslides" id="slider4">
			<li>
				<img src="<?php echo $webRoot?>theme/default/images/test_bg1.jpg" alt="">
			</li>
			<li>
				<img src="<?php echo $webRoot?>theme/default/images/test_bg2.jpg" alt="">
			</li>
		</ul>
	</div>
  </div>
  <div id="content">
    <div id="nave">
      <ul>
        <li class="nave_test_net active">IPv6网站检测</li>
        <li class="nave_test_addr">IPv6地址检测</li>
      </ul>
    </div>
    <div id="detection">
      <div id="title">
        <h4>IPv6网站检测 ：</h4>
        <span id="google">(如ipv6.cqbn.gov.cn)</span></div>
      <div id="search">
        <input type="text" id="netaddress"/>
        <span id="test_check" style="display:block;cursor:pointer"><img src="<?php echo $webRoot?>theme/default/images/detectionbutton.png" class="detectionbutton"/></span></div>
      <div id="result"> <span id="arrow"><img src="<?php echo $webRoot?>theme/default/images/arrow.png"/></span> <span id="text">这里显示检测结果</span></div>
      <div id="display">
		<span id="result_span"></span>  
	  </div>
    </div>
	<div id="test_addr" style="display:none">
		<div id="list1">
		  <h3>This page shows your IPv6 and/or IPv4 address . You are connecting with an 
			<span class="v4_v6" style="color:red;"></span> Address of:</h3>
		</div>
		<div id="list2">
		  <h3><span id="now_ip" style="color:#fff"></h3>
		</div>
		<div id="list3">
		  <ul>
			<li id="test_ipv4"><a href="javascript:void(0);" onclick="getipv4();">IPv4 only Test</a></li>
			<li id="test_v4_v6"><a href="javascript:void(0);" onclick="getip();">Normal Test</a></li>
			<li id="test_ipv6"><a href="javascript:void(0);" onclick="getipv6();">IPv6 only Test</a></li>
		  </ul>
		</div>
		<div id="list4">
		  <p>If the IPv6 only test shows "The page cannot be displayed" (Internet Explorer), "Server not found" (Firefox), any error or
			search page then you do not have working IPv6 connectivity. "Normal Test" shows which protocol your browser preferrs 
			when you have both IPv4 and IPv6 connectivity. This page should work even on computers with IPv6 only connectivity. </p>
		  <p>You can access this page with any of these easy to remember url's: </p>
		</div>
		<div id="list5">
		   <ul>
			<li><a href="http://ip4.me/" target="_blank">ip4.me</a>&nbsp;(defaults to IPv4 only test)</li>
			<li class="orange"><a href="http://ip6.me/" target="_blank">ip6.me </a></li>
			<li><a href="http://whatismyv6.com/" target="_blank">whatismyv6.com</a></li>
			<li><a href="http://whatismyipv6address.com/" target="_blank">whatismyipv6address.com</a></li>
		  </ul>
		</div>
	</div>
	<div style="clear:both"></div>
  </div>
  <div id="footer"><p>立普威陆（重庆）科技有限公司版权所有 - IPv6相关测试&nbsp;&nbsp;&nbsp;&nbsp;<script type="text/javascript">
		//页面访问量统计
		var cnzz_protocol = (("https:" == document.location.protocol) ? " https://" : " http://");document.write(unescape("%3Cspan id='cnzz_stat_icon_1257160509'%3E%3C/span%3E%3Cscript src='" + cnzz_protocol + "s11.cnzz.com/stat.php%3Fid%3D1257160509%26show%3Dpic' type='text/javascript'%3E%3C/script%3E"));
	</script></p></div>
</div>
<script type="text/javascript">
swfobject.registerObject("FlashID");

$(".nave_test_net").click(function(){
	$(this).addClass("active");
	$(this).next().removeClass("active");
	$("#detection").show();
	$("#test_addr").hide();
});
$(".nave_test_addr").click(function(){
	$(this).addClass("active");
	$(this).prev().removeClass("active");
	$("#detection").hide();
	$("#test_addr").show();
});

$(document).ready(function(e) {
	$("#test_check").click(function(){
		//alert(1);
	   var checkurl=$('#netaddress').val();
	   if(checkurl!=''){
		   $("#result_span").html('正在检测……');
		   $.post("<?php echo $this->createLink('index','check_url');?>",{checkurl:checkurl},
				function(data){
					var dataobj=$.parseJSON(data),
						html="";
						html+="<div class='result3'>检测站点：<span>"+dataobj.web+"</span></div>";
					if(dataobj.ipv6_status==0){
						html+="<div class='result4'>检测结果：<span>不具备IPv6访问功能</span></div>";
					}
					if(dataobj.ipv6_status==1){
						html+="<div class='result4'>检测结果：<span>具备IPv6访问功能</span></div>";
						html+="<div class='result5'>IPv6地址：<span>"+dataobj.ipv6+"</span></div>";
					}
					$("#result_span").html(html);
				});
	   }
	});
});

//页面访问量统计
	var cnzz_protocol = (("https:" == document.location.protocol) ? " https://" : " http://");document.write(unescape("%3Cspan id='cnzz_stat_icon_1257160509'%3E%3C/span%3E%3Cscript src='" + cnzz_protocol + "s11.cnzz.com/stat.php%3Fid%3D1257160509%26show%3Dpic' type='text/javascript'%3E%3C/script%3E"));
</script>
</body>
</html>
